package store

import (
	"errors"
	"io"
	"log"
	"os"
)

func ToLocal(location string, r io.Reader) error {
	localFile, err := os.Create(location)
	defer localFile.Close()
	if err != nil {
		log.Println(err)
		return errors.New("internal error")
	}
	_, err = io.Copy(localFile, r)
	if err != nil {
		log.Println(err)
		return errors.New("internal error")
	}
	return nil
}
